package com.ruoyi.project.cha.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.cha.domain.HosInq;
import com.ruoyi.project.cha.service.IHosInqService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 收费查询Controller
 * 
 * @author 朱鑫博
 * @date 2021-03-24
 */
@RestController
@RequestMapping("/cha/inq")
public class HosInqController extends BaseController
{
    @Autowired
    private IHosInqService hosInqService;

    /**
     * 查询收费查询列表
     */
    @PreAuthorize("@ss.hasPermi('cha:inq:list')")
    @GetMapping("/list")
    public TableDataInfo list(HosInq hosInq)
    {
        startPage();
        List<HosInq> list = hosInqService.selectHosInqList(hosInq);
        return getDataTable(list);
    }

    /**
     * 导出收费查询列表
     */
    @PreAuthorize("@ss.hasPermi('cha:inq:export')")
    @Log(title = "收费查询", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HosInq hosInq)
    {
        List<HosInq> list = hosInqService.selectHosInqList(hosInq);
        ExcelUtil<HosInq> util = new ExcelUtil<HosInq>(HosInq.class);
        return util.exportExcel(list, "inq");
    }

    /**
     * 获取收费查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('cha:inq:query')")
    @GetMapping(value = "/{inqNum}")
    public AjaxResult getInfo(@PathVariable("inqNum") Long inqNum)
    {
        return AjaxResult.success(hosInqService.selectHosInqById(inqNum));
    }

    /**
     * 新增收费查询
     */
    @PreAuthorize("@ss.hasPermi('cha:inq:add')")
    @Log(title = "收费查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HosInq hosInq)
    {
        return toAjax(hosInqService.insertHosInq(hosInq));
    }

    /**
     * 修改收费查询
     */
    @PreAuthorize("@ss.hasPermi('cha:inq:edit')")
    @Log(title = "收费查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HosInq hosInq)
    {
        return toAjax(hosInqService.updateHosInq(hosInq));
    }

    /**
     * 删除收费查询
     */
    @PreAuthorize("@ss.hasPermi('cha:inq:remove')")
    @Log(title = "收费查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inqNums}")
    public AjaxResult remove(@PathVariable Long[] inqNums)
    {
        return toAjax(hosInqService.deleteHosInqByIds(inqNums));
    }
}
